import requests
from requests.auth import HTTPDigestAuth


class Seetrum:

    # 保存配置参数
    # def __init__(self):
    #     self.s = requests.Session()
    #     self.detectorParams = self.get_detectorParams()['data']
    #     # self.s.params = { "access_token":self.token}

    # 封装获取检测配置参数
    def get_detectorParams(self):
        url = "https://169.254.169.1/v2/api/detectorParams"

        # r=requests.get("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=wwd429890af578a469&corpsecret=ooGtHdJ4_w8wn3auYijd-QO9SQmObz1GLBQ7mtW3J74")
        # r = requests.get(url,params=params)
        r = requests.get(url, verify=False, auth=HTTPDigestAuth('admin', 'Seetrum888', ))
        return r.json()


    # 获取控制配置参数
    def get_controlParams(self):
        url = "https://169.254.169.1/v2/api/controlParams"

        # r=requests.get("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=wwd429890af578a469&corpsecret=ooGtHdJ4_w8wn3auYijd-QO9SQmObz1GLBQ7mtW3J74")
        # r = requests.get(url,params=params)
        r = requests.get(url, verify=False, auth=HTTPDigestAuth('admin', 'Seetrum888', ))
        return r.json()

        # 获取控制配置参数

    def get_cropInfo(self):
        url = "https://169.254.169.1/v2/api/cropInfo"

        # r=requests.get("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=wwd429890af578a469&corpsecret=ooGtHdJ4_w8wn3auYijd-QO9SQmObz1GLBQ7mtW3J74")
        # r = requests.get(url,params=params)
        r = requests.get(url, verify=False, auth=HTTPDigestAuth('admin', 'Seetrum888', ))
        return r.json()
